package com.ezops.dto;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import com.fasterxml.jackson.annotation.JsonProperty;

public class CashClearerResultData implements Serializable {
	
	public static List<Object> adaptToData(Map<String, Map<String, CashByClearerSeriesCurrencyData>> SeriesData, Map<String, CashByClearerSeriesDrildownData> drilldownData){
		Iterator<Entry<String, Map<String, CashByClearerSeriesCurrencyData>>> itr = SeriesData.entrySet().iterator();
		List<CashClearerResultData> clearerSeriesResult = new ArrayList<>();
		while(itr.hasNext())
		{
			Entry<String, Map<String, CashByClearerSeriesCurrencyData>> nextVal=itr.next();
			CashClearerResultData model = new CashClearerResultData();
			model.setName(nextVal.getKey());
			model.setAllData(new ArrayList<>(nextVal.getValue().values()));
			clearerSeriesResult.add(model);
		}
		Map<String, Object> drilldownMap = adaptTo(drilldownData);
		List<Object> resultList = new ArrayList<>();
		resultList.add(clearerSeriesResult);
		resultList.add(drilldownMap);
		return resultList;
	}
	
	public static Map<String, Object> adaptTo(Map<String, CashByClearerSeriesDrildownData> drilldownData){
		//CashByClearerSeriesDrildownData obj = new CashByClearerSeriesDrildownData();
		Map<String, Object> map = new HashMap<>();
		map.put("drilldownData", drilldownData.values());
		//obj.setDrillDataList(new ArrayList<>(drilldownData.values()));
		//drilldownList.add(obj);
		return map;
	}
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 832242824697395393L;
	private String name;
	@JsonProperty("data")
	private List<CashByClearerSeriesCurrencyData> seriesData = new ArrayList<CashByClearerSeriesCurrencyData>();
	
	public String getName() {
		return name;
	}
	public List<CashByClearerSeriesCurrencyData> getSeriesData() {
		return seriesData;
	}

	public void setName(String name) {
		this.name = name;
	}
	public void setAllData(List<CashByClearerSeriesCurrencyData> ObjDataList) {
		this.seriesData.addAll(ObjDataList);
	}
	
}
